
source ../sys/.env
#start=$(date +%s)
source .env
D_MESSAGE=d_message.txt
echo ${RUNRESBASE}
MODULE_BASE=${RUNRESBASE}/Struct
if ! [ -d ${MODULE_BASE} ]; then
 mkdir ${MODULE_BASE}
fi
MYLOG_BASE=${RUNRESBASE}/Struct/logfiles
if ! [ -d ${MYLOG_BASE} ]; then
 mkdir ${MYLOG_BASE}
fi
logfile=$MYLOG_BASE/$1.log
rm -f $logfile
touch $logfile
cd ../Struct
#./run_geo_build.sh $1|tee -a ${logfile}
# make display 
check_anba=${RUNRESBASE}/Struct/check_state.log
check_mesh2d=${RUNRESBASE}/Struct/check_state.log
if [ $1 = "step04" ];then
  make $1 & >$logfile
  sleep 2
  while [ "1" = "1" ]
  do
    state=`cat ${logfile}|grep ANBA_END`
    if [ ${state} = "ANBA_END" ]; then
       echo $state>$check_anba
       break
    fi
    sleep 1
    #tail -F ${logfile} >$D_MESSAGE
  done
  rm stiffness/*.*
  cp ./temp_b3ps_portable/*.json ./stiffness 
fi
if [ $1 = "step03" ];then
  make $1 &
  while [ "1" = "1" ]
  do
    state=`cat ${logfile}|grep MESH2D_END`
    if [ ${state} = "MESH2D_END" ]; then
     echo $state>$check_mesh2d
     break
    fi
    sleep 1
    #tail -F ${logfile} >$D_MESSAGE
  done
fi
make $1
